﻿using Cache;
using DtoFw;
using DtoFw.Base;
using DtoFw.Query;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace SceneEvidenceAPI.Controllers
{
    /// <summary>
    /// 第三方接口
    /// </summary>
    [Route("api/query")]
    public class QueryController : BaseController
    {
        private readonly QueryService _queryService;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="queryService"></param>
        public QueryController(QueryService queryService)
        {
            this._queryService = queryService;
        }

        /// <summary>
        /// 查询案件
        /// </summary>
        /// <returns></returns>
        [HttpPost("queryCase")]
        public BaseGenericResult<Pager<QueryCaseDto>> QueryCase(QueryCaseDto dto)
        {
            var _user = TokenHelper.GetTokenInfo<TokenData>(User);
            return _queryService.QueryCase(dto, _user);
        }

        /// <summary>
        /// 物品查询
        /// </summary>
        /// <returns></returns>
        [HttpPost("queryEvidence")]
        public BaseGenericResult<Pager<QueryEvidenceDto>> QueryEvidence(QueryEvidenceDto dto)
        {
            var _user = TokenHelper.GetTokenInfo<TokenData>(User);
            return _queryService.QueryEvidence(dto, _user);
        }


        /// <summary>
        /// 硕源查询
        /// </summary>
        /// <returns></returns>
        [HttpPost("querySource")]
        public BaseGenericResult<QuerySourceDto> QuerySource(QueryDto dto)
        {
            var _user = TokenHelper.GetTokenInfo<TokenData>(User);
            return _queryService.QuerySource(dto, _user);
        }



        /// <summary>
        /// 一键查询
        /// </summary>
        /// <returns></returns>
        [HttpGet("{page}/{pageSize}/queryInfo/{key}")]
        public BaseGenericResult<Pager<QueryEvidenceDto>> QueryInfo(int page, int pageSize, string key)
        {
            var _user = TokenHelper.GetTokenInfo<TokenData>(User);
            return _queryService.QueryInfo(key, page, pageSize, _user);
        }

    }
}
